<layout name="all@index/indexlayout" />
<script type="text/javascript" src="{$ROOT}/js/md5.js"></script>
<script>
        $(function () {
            //密码框回车提交
            $('#pwd').keydown(function(e){
                if(e.keyCode==13){
                    login_click();
                }
            });
            if('{$page.many}'<=3){
                $('#valid').hide();
                $('#code').hide();
            }
            else{
                $('#loginForm').height(300);
            }
        });
        function login_click(){
            var username=$('#username').val();
            var pwd=$('#pwd').val();
            if(!$("#loginForm").form('validate')||username==''||pwd=='') return;

            pwd=hex_md5(hex_md5(pwd)+'{$page.guid}');
            $.post('{$ROOT}/home/login/checklogin',{username:username,pwd:pwd,code:$('#code').val()},function(result){
                if (result.status==1||result.status==2){
                    location="{$ROOT}/admin/index/index";
                }
                else {
                    if(result.status==-1)
                        $('#valid').click();
                    if(result.times>3&&result.status==0){ //如果密码输入错误，刷新页面
                        location=getURLString()+'?t='+Math.random();
                    }
                    $.messager.alert("错误",result.info,"error",pwdselect);

                }
            },'json');
        }
        //提示密码错误后选中密码输入框
        function pwdselect()
        {
            var a=$('#pwd');
            a.select();
            a.focus();
        }
    </script>
<style type="text/css">
    *{
        margin:0;
        padding:0;
        list-style: none;
    }
    body{
        background:url("{$ROOT}/img/bg.png") repeat;
    }
    #all{
        width:1000px;
        margin:0 auto;
    }
    #head{
        width:100%;
        height:150px;
        background: url("{$ROOT}/img/logo.png") no-repeat;
    }
    #content{
        position: relative;
        height:500px;
        width: 100%;
        background:url("{$ROOT}/img/school{$page.order}.jpg") no-repeat ;
    }
    #loginForm{
        -moz-border-radius: 5px;
        -webkit-border-radius: 5px;
        border-radius:5px;
        position: absolute;
        top:140px;
        left:660px;
        border:1px #cc9933 solid;
        width:250px;
        height:250px;
        background-color: #E0ECFF;
    }
    #valid{
        position: absolute;;
        top:185px;
        left:120px;
        z-index: 999;;
    }
    #loginForm input,#loginbt{
        display: block;
        height:40px;
        border:1px silver solid;
        margin:15px auto;
        padding-left:35px;
        width:150px;
    }
    input#code{
        width:60px;
        margin-left: 30px;
        padding: 0 10px;
        text-align: center;
        font-size: 14px;
        font-weight:bold;
        word-spacing:20px;
    }
    #tip{
        display: block;
        line-height: 40px;
        height: 40px;
        padding-left: 40px;
        background-color:#CC9933;
        font-weight: bold;
        margin-bottom: 30px;
        background-image: url("{$ROOT}/img/user_tip.png");
        background-repeat: no-repeat;
        background-position: 5px center ;
    }
    #username{
        background:url("{$ROOT}/img/user.png") no-repeat left seashell;
    }
    #pwd{
        background:url("{$ROOT}/img/lock.png") no-repeat left seashell;
    }
    #loginbt{
        padding-left: 0;
        line-height: 40px;
        text-align: center;
        background-color:#FFCC00;
        width:185px;
        color:#000;
    }
    #loginbt:hover{
        background-color: #FF9933;
        color:#FFF;
    }
    #footer{
        height:50px;
        line-height:50px;
    }
</style>
<body>
<div id="all">
    <div id="head"> </div>
    <div id="content">
        <form action="" method="post" name="loginForm" id="loginForm">
            <span id="tip">账户登录</span>
            <input type="text" name="username" id="username"  placeholder="教师号或者学号"/>
            <input type="password" name="pwd" id="pwd"   placeholder="输入密码" />
            <input type="text"  id="code"   placeholder="验证码" size="4" maxlength="4"/>
            <img id="valid" src="{$ROOT}/all/option/verify"  onclick="this.src='{$ROOT}/all/option/verify?id='+Math.random();" >
            <a onclick="login_click()" id="loginbt" href="javascript:void(0)">用户登录</a>
        </form>
    </div>
    <div id="footer"> {$COPYRIGHT}</div>
</div>
</body>
</html>
